package com.js.basicpage.activity;

// Created by JS on 2021/1/18.

import android.app.Dialog;
import android.content.Context;

import androidx.appcompat.app.AppCompatActivity;

import com.js.basicpage.R;
import com.js.basicpage.widget.LoadingDialog;

public class BaseLoadingDialogActivity extends AppCompatActivity {

    private static LoadingDialog sProgressDialog;

    public static synchronized void showDialog(Context context, String msg) {
        if (null == context) {
            return;
        }
        final LoadingDialog dialog = new LoadingDialog(context, R.style.Loading);
        dialog.setMessage(msg);
        sProgressDialog = dialog;
        sProgressDialog.show();
    }

    public static synchronized  void showDialog(Context context) {
        showDialog(context,"加载数据中...");
    }

    public static synchronized void dismissDialog() {
        if (null != sProgressDialog && sProgressDialog.isShowing()) {
            try {
                sProgressDialog.dismiss();
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }

        }
    }

    public static Dialog getProgressDialog() {
        return sProgressDialog;
    }

    public static void setDialogMassage(String massage) {
        if (sProgressDialog == null) return;
        sProgressDialog.setMessage(massage);
    }
}
